Sidebar Label and Redundancy Troubleshooting
This guide explains how we fixed the issue with folder names not appearing correctly in the sidebar and how to handle redundant names.
1. Fixing Stripped Number Prefixes
The Problem
Docusaurus automatically strips numbers like 01., 10., etc., from folder names when generating sidebar labels. It uses these numbers only for sorting.
The Solution: _category_.json
To force Docusaurus to show the full name (e.g., "10. Troubleshooting"), we created a _category_.json file inside the folder:
Path: /opt/docker-data/apps/docusaurus/site/docs/knowledge/docusaurus/10. Troubleshooting/_category_.json
{
"label": "10. Troubleshooting",
"position": 10,
"link": {
"type": "generated-index"
}
}
2. Removing Redundant Sidebar Items
The Problem
When you add an index.md to a category folder, Docusaurus creates a nested sidebar item with the same name as the category, which looks redundant.
The Solution: sidebar_class_name: hidden
We hidden the internal index.md from the sidebar while keeping the folder (category) visible. This is done by adding frontmatter to the index.md file:
Path: /opt/docker-data/apps/docusaurus/site/docs/knowledge/docusaurus/10. Troubleshooting/index.md
---
sidebar_class_name: hidden
---
# 10. Troubleshooting
...
3. Summary of Steps Taken
- Created
_category_.json: To fix the label "10. Troubleshooting". - Created
index.md: To provide a landing page for the category. - Updated
index.mdFrontmatter: Addedsidebar_class_name: hiddento remove the redundant nested link in the sidebar. - Restarted Service: Ran
sudo docker restart docusaurusto apply changes.
Management Reference
| Action | File | Property |
|---|---|---|
| Change Folder Label | _category_.json | "label": "New Name" |
| Hide Item from Sidebar | .md file | sidebar_class_name: hidden |
| Reorder Category | _category_.json | "position": X |